'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    baseController = require('../../../Base/server/controllers/BaseDoc.js');

var newModel = baseController.getBaseDocFields();
newModel.Code = {
    type: String,
    unique: '编码已存在',
    required: '请输入编码',
    trim: true
};

newModel.Name = {
    type: String,
    required: '请录入名称',
    trim: true
};

newModel.Menus = {
    type: [
        {
            type: Schema.ObjectId,
            ref: 'Menu'
        }
    ]
};

newModel.IsEffective = {
    type: Boolean
};

newModel.Remark = {
    type: String,
    default: '',
    trim: true
};

var newSchema = new Schema(newModel);
newSchema.index({Name: 1});
newSchema.index({Code: 1}, {"unique": true});

mongoose.model('Role', newSchema, 'Role');
